# -*- coding: utf-8 -*-

from openerp import http
from openerp.http import request
from openerp.addons.website_sale.controllers.main import website_sale


class website_sale(website_sale):

    @http.route(['/shop/cart'], type='http', auth="public", website=True)
    def cart(self, **post):
        request.session['get_cart'] = True

        return super(website_sale, self).cart(**post)

    @http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True)
    def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
        request.session['get_cart'] = True

        return super(website_sale, self).cart_update(product_id, add_qty=add_qty, set_qty=set_qty, **kw)

    @http.route(['/shop/cart/update_json'], type='json', auth="public", methods=['POST'], website=True)
    def cart_update_json(self, product_id, line_id, add_qty=None, set_qty=None, display=True):
        request.session['get_cart'] = True

        return super(website_sale, self).cart_update_json(product_id, line_id,
            add_qty=add_qty, set_qty=set_qty, display=display)

    @http.route(['/shop/checkout'], type='http', auth="public", website=True)
    def checkout(self, **post):
        request.session['get_cart'] = False
        request.session['sale_order_id'] = False

        return super(website_sale, self).checkout(**post)
